
import type { FilterRuleOptions, TypeConfig, RuleGenerationResult } from './types';
import { createBaseRule } from './ruleGeneratorUtils';

const skillGemConfig: TypeConfig = {
    class: 'Gem',
    icon: 'Cyan',
    iconShape: 'Hexagon',
    name: '技能石',
    fontSize: 45
};

export function generateSkillGemRule(options: FilterRuleOptions): RuleGenerationResult {
    let baseResult = createBaseRule(options, {
        name: skillGemConfig.name,
        class: skillGemConfig.class,
        defaultColor: '#00FFFF',  // 青色作为技能石的默认颜色
        defaultBgColor: '#000000',
        fontSize: skillGemConfig.fontSize,
        icon: skillGemConfig.icon,
        iconShape: skillGemConfig.iconShape
    });

    // 如果规则无效或被禁用，直接返回
    if (!baseResult.isValid || !baseResult.content) {
        return baseResult;
    }

    // 添加技能石特有的等级要求
    if (options.tap) {
        const lines = baseResult.content.split('\n');
        const insertIndex = lines.findIndex(line => line.includes('BaseType')) + 1;
        lines.splice(insertIndex, 0, `  GemLevel ${options.tap}`);
        baseResult.content = lines.join('\n');
    }

    return baseResult;
}